package com.ayz.gateway.common.result;

import lombok.Data;

/**
 * @ClassName GatewayResult
 * @Description TODO: 网关通用返回对象
 * @Author 快乐的星球
 * @Date 2023/5/10 17:21
 * @Version 1.0
 **/
@Data
public class GatewayResult {
    /**
     * 结果码
     */
    private int code;
    /**
     * 结果描述信息
     */
    private String msg;
    /**
     * 数据对象
     */
    private Object data;

    public GatewayResult(int code,String msg){
        this.code=code;
        this.msg=msg;
    }


    public GatewayResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public GatewayResult(int code,Object data){
        this.code=code;
        this.data=data;
    }

    public static GatewayResult success(Object data){
        return new GatewayResult(ResponseCode.COMMON_SUCCESS,data);
    }

    public static GatewayResult error(String msg){
        return new GatewayResult(ResponseCode.COMMON_ERROR,msg);
    }

    public static GatewayResult success(int code,Object data){
        return new GatewayResult(code,data);
    }

    public static GatewayResult error(int code,String msg){
        return new GatewayResult(code,msg);
    }

    public static GatewayResult success(){
        return new GatewayResult(ResponseCode.COMMON_SUCCESS,"success");
    }
}
